package com.example.demo_mysql_mybatisplus.util.easyexcel.exports.simple_export.ReadMe.demos.dtos;

import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.format.DateTimeFormat;
import com.example.demo_mysql_mybatisplus.util.easyexcel.converters.BoolEnumConverter;
import com.example.demo_mysql_mybatisplus.util.easyexcel.converters.GenderConverter;
import com.example.demo_mysql_mybatisplus.util.easyexcel.converters.LongStrConverter;
import com.example.demo_mysql_mybatisplus.util.easyexcel.converters.vo.HyperlinkVo;
import com.example.demo_mysql_mybatisplus.util.easyexcel.enums.BoolEnum;
import com.example.demo_mysql_mybatisplus.util.easyexcel.exports.customized.comment.HeadComment;
import com.example.demo_mysql_mybatisplus.util.easyexcel.exports.customized.selected.ExcelSelected;
import com.example.demo_mysql_mybatisplus.util.easyexcel.exports.dtos.dynamicSelecteds.BooleanEnumSelected;
import com.example.demo_mysql_mybatisplus.util.easyexcel.exports.dtos.dynamicSelecteds.DbFieldSelected;
import lombok.Data;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Data
@Accessors(chain = true)
public class DemoData implements Serializable {
    private static final long serialVersionUID = 1L;

    /////////////////////////////////////// 基础操作
    @ExcelProperty(value = "数字" /*,index=0 ,order = 0*/) // 索引>顺序>默认排序
    private long num;
    @ExcelProperty(value = "数字2", converter = LongStrConverter.class)
    private Long num2;
    @ExcelProperty("字符串")
    private String str;
    @ExcelProperty("日期时间")
    @DateTimeFormat("yyyy-MM-dd HH:mm:ss")
    @HeadComment("格式：\r\nyyyy-MM-dd HH:mm:ss")
    private Date dateTime;
    @ExcelProperty(value = "INT2STR", converter = GenderConverter.class)  // 关联‘GenderConverter’
    private int int2str;
    @ExcelProperty("布尔")
    private boolean boo;
    @ExcelProperty(value = "枚举", converter = BoolEnumConverter.class)  // 关联‘BoolEnumConverter’
    private BoolEnum enumer;

    @ExcelIgnore
    private String str_ignore;

    private String 字段_1;

    private String 字段_2;

    /////////////////////////////////////// 扩展操作
    //固定下拉框  （关联customized.selected ）
    @ExcelProperty(value = "下拉框-固定")
    @ExcelSelected(source = {"耗材", "普通设备", "医疗设备"})
    private String dropdownBox_fixed;
    //动态下拉框：枚举数据显示在下拉框中  （关联customized.selected ; 要定义‘dynamicSelect’）
    @ExcelProperty(value = "下拉框-枚举", converter = BoolEnumConverter.class)
    @ExcelSelected(sourceClass = BooleanEnumSelected.class)
    private BoolEnum dropdownBox_enum;
    //动态下拉框：可以查询数据库数据显示在下拉框中  （关联customized.selected ; 要定义‘dynamicSelect’）
    @ExcelProperty(value = "下拉框-数据库")
    @ExcelSelected(sourceClass = DbFieldSelected.class)
    private String dropdownBox_db;

    // 待批注的字段  （关联customized.comment ）
    @HeadComment("这个是批注内容。")
    @ExcelProperty(value = "批注字段")
    private String commentField;

    //    @ExcelProperty(value = "超链接-1" , converter = HyperlinkConverter.class)
    private HyperlinkVo link;

    // TODO
    @ExcelProperty(value = "图片")
    private String imagePath;


    public static List<DemoData> getDemoDatas() {
        ArrayList list = new ArrayList();
        list.add(new DemoData().setNum(1).setNum2(11L).setStr("a").setBoo(false).setLink(new HyperlinkVo().setAddress("南巷苑-1"))
                .setDateTime(new Date())
        );
        list.add(new DemoData().setNum(2).setNum2(22L).setStr("b").setBoo(true).setLink(new HyperlinkVo().setAddress("南巷苑-2"))
                .setDateTime(new Date())
        );
        list.add(new DemoData().setNum(3).setNum2(33L).setStr("c").setBoo(false).setLink(new HyperlinkVo().setAddress("南巷苑-3"))
                .setDateTime(new Date())
        );
        list.add(new DemoData().setNum(4).setNum2(44L).setStr("d").setBoo(true).setLink(new HyperlinkVo().setAddress("南巷苑-4"))
                .setDateTime(new Date())
        );
        list.add(new DemoData().setNum(5).setNum2(55L).setStr("e").setBoo(false).setLink(new HyperlinkVo().setAddress("南巷苑-5"))
                .setDateTime(new Date())
        );
        list.add(new DemoData().setNum(6).setNum2(77L).setStr("f").setBoo(true).setLink(new HyperlinkVo().setAddress("南巷苑-6"))
                .setDateTime(new Date())
        );
        return list;
    }

}
